<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "set_url_crawler".
 *
 * @property int $id
 * @property string $url 采集路径
 * @property string $match 匹配规则
 * @property int $max_pages_crawl 最大抓取页面数
 * @property string $output_file_name 抓取后文件存储路径
 * @property int $max_tokens 文件类型
 * @property string|null $status 状态
 * @property string|null $res_url 结果路径
 * @property string|null $err_msg 错误信息
 * @property string|null $url_user 是否使用
 * @property string|null $created_at 创建时间
 * @property string|null $used_at 使用时间
 * @property string|null $rss_sitemap_id set_rss_sitemap_crawler.id,为0时与set_rss_sitemap_crawler无关联
 */
class SetUrlCrawler extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'set_url_crawler';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['url'], 'required'],
            [['max_pages_crawl', 'max_tokens','rss_sitemap_id'], 'integer'],
            [['status', 'res_url','err_msg'], 'string'],
            [['url_user','created_at','used_at'], 'safe'],
            [['url'], 'string', 'max' => 500],
            [['match', 'output_file_name'], 'string', 'max' => 300],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'url' => 'Url',
            'match' => 'Match',
            'max_pages_crawl' => 'Max Pages Crawl',
            'output_file_name' => 'Output File Name',
            'max_tokens' => 'Max Tokens',
            'status' => 'Status',
            'res_url' => 'Res Url',
        ];
    }

    public function getRss(){
        return $this->hasOne(SetRssSitemapCrawler::class,['id'=>'rss_sitemap_id']);
    }
}
